package com.atguigu.gmall.product.controller.api;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.common.cache.Java0828GmallCache;
import com.atguigu.gmall.product.service.BaseCategoryViewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/***
 * 商品首页的控制层
 */
@RestController
@RequestMapping("/api/index")
public class ApiBaseCategoryViewController {

    @Autowired
    private BaseCategoryViewService baseCategoryViewService;

    @Java0828GmallCache
    @GetMapping("/listCategory")
    public List<JSONObject> listCategory(){
        //调用业务层方法
        List<JSONObject> categoryList = baseCategoryViewService.listIndexCategory();

        //2 响应数据
        return categoryList;
    }
}
